
import 'package:flutter/material.dart';
import 'package:flutter_deer/index/models/user_betting_entity.dart';
import 'package:flutter_deer/widgets/state_layout.dart';

class IndentListPageProvider extends ChangeNotifier {

  UserBettingPageEntity? _bettingPage;
  List<UserBettingEntity>? _list = [];
  StateType? _stateType = StateType.loading;
  int? _currentPage = 1;

  UserBettingPageEntity? get bettingPage => _bettingPage;
  int? get total => _bettingPage!.total;
  int? get current => _bettingPage!.current;
  List<UserBettingEntity>? get records => _bettingPage!.records;
  List<UserBettingEntity>? get list => _list;
  bool? get hasMore => _bettingPage!.current != _bettingPage!.pages;
  StateType? get stateType => _stateType;
  int? get currentPage => _currentPage;

  void setBettingPage(UserBettingPageEntity? pageEntity){
    this._bettingPage = pageEntity;
    this._currentPage = pageEntity?.current;
    if(this._currentPage == 1){
      this._list = pageEntity!.records;
    }else{
      for(int i=0;i<pageEntity!.records!.length;i++){
        UserBettingEntity? item = pageEntity.records!.elementAt(i);
        this._list!.add(item);
      }
    }
    this._stateType = StateType.order;
    notifyListeners();
  }

}